<#include "../common/_public.html"/>
    <link rel="stylesheet" href="${base}/layui/css/layui.css"  media="all">
<form class="layui-form" id="change_password_form">
<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header">修改密码</div>
        <div class="layui-card-body" pad15>
          <input type="hidden" name="userId" value="${userId!}">
          <div class="layui-form" lay-filter="">
            <div class="layui-form-item">
              <label class="layui-form-label">当前密码</label>
              <div class="layui-input-inline">
                <input type="password" name="old_password" lay-verify="required" lay-verType="tips" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">新密码</label>
              <div class="layui-input-inline">
                <input type="password" name="now_password" lay-verify="pass|required" lay-verType="tips" autocomplete="off" id="LAY_password" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux"></div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">确认新密码</label>
              <div class="layui-input-inline">
                <input type="password"  id="LAY_rePassword"lay-verify="pass|required" lay-verType="tips" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="change_pass">确认修改</button>
              </div>
            </div>
          </div>
          
        </div>
      </div>
    </div>
  </div>
</div>
</form>
<script src="${base}/layui/layui.js" charset="UTF-8"></script>
<script>
    layui.use(['layer','form','element'], function(){
        var layer = layui.layer,
                form = layui.form,
                $ = layui.$;

        var url = '${base}/system/user_changePassword.do';
        var loginUrl = '${base}/logout.do';
        form.verify({
            pass: [/(.+){6,18}$/, '密码必须6到12位']
        });
        form.on('submit(change_pass)', function(data){
            var pass = $("#LAY_password").val();
            var repass = $("#LAY_rePassword").val();
            if(repass != pass){
                layer.msg("两次密码输入不一致",{
                    icon:5,
                    time:2000,
                    shift: 6
                });
                return false;
            }
            $.ajax({
                type:"post",
                url:url,
                data:$("#change_password_form").serialize(),
                dataType:"json",
                success:function(result) {
                    if(result.statusCode == 200){
                        layer.msg(result.message,{
                            icon:1,
                            time:1500
                        }, function(){
                            //parent.tools.closed();
                            parent.tools.logout_now();
                        })
                    }else if(result.statusCode == 300){
                        layer.msg(result.message,{
                            icon:2,
                            time:2000
                        },function () {
                            parent.tools.refresh();
                        });
                    }
                }
            })
            return false;
        });
    });
</script>